package com.example.bluetoothserialport

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.Gravity
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.azhon.appupdate.manager.DownloadManager
import mehdi.sakout.aboutpage.AboutPage
import mehdi.sakout.aboutpage.Element

class AboutActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_about)

        val authorElement1 = Element()
        authorElement1.gravity = Gravity.CENTER
        authorElement1.title = "成员1：唐富春 "
        authorElement1.setOnClickListener {
            Toast.makeText(this,"不要点我！你可以点下面那一位^_^",Toast.LENGTH_SHORT).show()
        }

        val authorElement2 = Element()
        authorElement2.gravity = Gravity.CENTER
        authorElement2.title = "成员2：陈建辉"
        authorElement2.setOnClickListener {
            Toast.makeText(this,"既然点到我了，那我就给你说一个秘密：点击下面那一位有惊喜",Toast.LENGTH_SHORT).show()
        }

        val authorElement3 = Element()
        authorElement3.gravity = Gravity.CENTER
        authorElement3.title = "成员3：江    莉"
        authorElement3.setOnClickListener {
            Toast.makeText(this,"这里没有惊喜。但是你可以试着点击下面的版本号。",Toast.LENGTH_SHORT).show()
        }

        val versionElement = Element()
        val localVersionName = packageManager.getPackageInfo(packageName,0).versionName
        versionElement.gravity = Gravity.CENTER
        versionElement.title = localVersionName
        versionElement.setOnClickListener {
            Toast.makeText(this,"这是一个乱输入的数字，不要相信它。但是下面那个是真的。",Toast.LENGTH_SHORT).show()
        }

        val buttonBackElement = Element()
        buttonBackElement.gravity = Gravity.CENTER
        buttonBackElement.title = "返回"
        buttonBackElement.setOnClickListener {
            Toast.makeText(this,"既然你点了返回，那就只有返回了。欢迎下次再来。",Toast.LENGTH_SHORT).show()
            finish()
        }

        val aboutPage: View = AboutPage(this)
            .isRTL(false)
            .setDescription("向日葵队的蓝牙串口软件")
            .setImage(R.mipmap.ic_launcher)
            .addGroup("向日葵队成员：")
            .addItem(authorElement1)
            .addItem(authorElement2)
            .addItem(authorElement3)
            .addGroup("版本号：")
            .addItem(versionElement)
            .addGroup("返回：")
            .addItem(buttonBackElement)
            .create()
        setContentView(aboutPage)
    }
}
